<script setup>
import { ref, watch } from "vue";

const totalCount = ref(10);

const msg = ref("震惊！");

watch([totalCount, msg], (oldValue, newValue) => {
  console.log("totalCount改变了", totalCount.value);
  console.log({ oldValue, newValue });
});
</script>

<template>
  <p>计数器：{{ totalCount }}</p>
  <p>{{ msg }}</p>
  <button @click="totalCount++">点击+1</button>
  <button @click="msg += '!'">点击继续震惊</button>
</template>